#include "inode.h"



uint8_t inode_list_del(vfs_node_t **list, char *name)
{
	vfs_node_t *t = *list;
	vfs_node_t *a;
	
	while(t != NULL)
	{
		if(strcmp(t->name, name) == 0)
		{
			if(t == *list)
			{
				*list = t->next;
				t->next->prev = *list;
				(*list)->prev = NULL;
				free(t);
			}
			else
			{
				t->next->prev = t->prev;
				t->prev->next = t->next;
				
				free(t);
			}
			
			return 1;
		}
		
		t = t->next;
	}
	return 0;		
}

uint8_t inode_list_clear(vfs_node_t **list)
{
	vfs_node_t *t = *list;
	vfs_node_t *a;
	
	while(t != NULL)
	{
		a = t->next;
		free(t);
		t = a;
	}	
}

uint8_t inode_list_add(vfs_node_t **list, vfs_node_t *inode)
{
	inode->next = *list;
	inode->prev = NULL;
	inode->next->prev = inode;
	*list = inode;	
	
	return 1;
}


uint8_t inode_list_check(vfs_node_t **list, char *name)
{
	vfs_node_t *t = *list;
	
	while(t != NULL)
	{
		if(strcmp(t->name, name) == 0) return 1;
		t = t->next;
	}
	return 0;	
}
